﻿namespace Basic.Oss.Interfaces;

/// <summary>
/// OSS云存储通用接口
/// </summary>
public interface IOssService
{
    /// <summary>
    /// 获取文件路径
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    string GetFileUrl(string ossFileName);

    #region 同步方法

    /// <summary>
    /// 获取文件流
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Stream GetFileStream(string ossFileName);

    /// <summary>
    /// 获取文件字节流
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    byte[] GetFileBytes(string ossFileName);

    /// <summary>
    /// 上传文件流
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="ossFileName"></param>
    bool PutFile(Stream stream, string ossFileName);

    /// <summary>
    /// 上传字节流
    /// </summary>
    /// <param name="bytes"></param>
    /// <param name="ossFileName"></param>
    bool PutFile(byte[] bytes, string ossFileName);

    /// <summary>
    /// 删除文件
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    bool DeleteFile(string ossFileName);

    #endregion

    #region 异步方法

    /// <summary>
    /// 获取文件流
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Task<Stream> GetFileStreamAsync(string ossFileName);

    /// <summary>
    /// 获取文件字节流
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Task<byte[]> GetFileBytesAsync(string ossFileName);

    /// <summary>
    /// 上传文件流
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Task<bool> PutFileAsync(Stream stream, string ossFileName);

    /// <summary>
    /// 上传文件流
    /// </summary>
    /// <param name="bytes"></param>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Task<bool> PutFileAsync(byte[] bytes, string ossFileName);

    /// <summary>
    /// 删除文件
    /// </summary>
    /// <param name="ossFileName"></param>
    /// <returns></returns>
    Task<bool> DeleteFileAsync(string ossFileName);

    #endregion
}